package com.project.web.intfc.controller.common;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yun.common.utils.ip.IpUtils;
import org.yun.common.utils.redis.RedisClient;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 公共接口
 *
 * @author WYY
 * @date 2018/11/06
 */
@Controller("appInterfaceCommonController")
@RequestMapping("/interface/common")
public class CommonController extends BaseController {
    private static final long serialVersionUID = 4960802971662679097L;

    @Resource(name = "redisClient")
    private RedisClient redisClient;

    /**
     * 获取真实ip
     *
     * @param request
     * @return
     */
    @RequestMapping("/getIPAddress")
    @ResponseBody
    public Map getIPAddress(HttpServletRequest request) {
        Map result = new HashMap<>();
        result.put("ip", IpUtils.getIpAddr(request));
        return getResult(result);
    }
}
